using System;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using Granite.Commons.Metadata;

namespace LeadTracker.Models
{
	public class LeadCommentModel : global::Granite.Modeling.ChangeTrackingModelBase
	{
		public LeadCommentModel()
		{

		}

		public LeadCommentModel(IDictionary<string, object> fields)
		{
			Load(fields);
		}

		[CalculatedField("LeadCommentKey")]
		public bool IsNew
		{
			get { return !LeadCommentKey.HasValue; }
		}


		[Action("Select")]
		[Action("Delete")]
		public int? LeadCommentKey
		{
			get { return GetOrDefault<int?>("LeadCommentKey"); }
		}

		[Action("Insert")]
		[Action("Update")]
		public int LeadKey
		{
			get { return GetOrDefault<int>("LeadKey"); }
			set { SetValue("LeadKey", value); }
		}

		[Action("Insert")]
		[Action("Update")]
		[DataType(DataType.MultilineText)]
		[Required]
		public string Comment
		{
			get { return GetOrDefault("Comment", ""); }
			set { SetValue("Comment", value); }
		}


		public int? CreatedByKey
		{
			get { return GetOrDefault<int?>("CreatedByKey"); }
		}


		public DateTimeOffset? CreatedDate
		{
			get { return GetOrDefault<DateTimeOffset?>("CreatedDate"); }
		}


		public override string ToString()
		{
			return Comment;
		}
	}
}
